# coding=utf-8
from .common import ConfigBase
from ...client import compFactory, levelId

_configClientComp = compFactory.CreateConfigClient(levelId)


class Config(ConfigBase):

    @classmethod
    def create(cls):
        self = cls()
        data = _configClientComp.GetConfigData(cls.getKey(), cls.isGlobal())
        if isinstance(data, dict):
            self.deserialize(data)
        return self

    def persistence(self):
        _configClientComp.SetConfigData(self.getKey(), self.serialize(), self.isGlobal())
